package com.zhlb.zfba.modules.per.service;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhlb.zfba.common.utils.DateUtil;
import com.zhlb.zfba.common.utils.IdGen;
import com.zhlb.zfba.modules.card.bean.CardRegInfo;
import com.zhlb.zfba.modules.card.service.CardRegInfoService;
import com.zhlb.zfba.modules.per.bean.GoodsInfo;
import com.zhlb.zfba.modules.per.bean.PoliceInfo;
import com.zhlb.zfba.modules.per.bean.SuspectInfo;
import com.zhlb.zfba.modules.per.bean.UserInfo;
import com.zhlb.zfba.modules.per.dao.GoodsInfoDao;
import com.zhlb.zfba.modules.per.dao.PoliceInfoDao;
import com.zhlb.zfba.modules.per.dao.SuspectInfoDao;
import com.zhlb.zfba.modules.per.dao.UserInfoDao;

@Service
@Transactional(readOnly = true)
public class UserInfoService {
	@Autowired
	UserInfoDao userInfoDao;
	public UserInfo get(String id) {
		return userInfoDao.get(id);
	}
	public UserInfo getByLoginName(String loginname) {
		return userInfoDao.getByLoginName(loginname);
	}
	
	
	public List<UserInfo> findList(UserInfo userInfo) {
		return userInfoDao.findList(userInfo);
	}

	@Transactional(readOnly = false)
	public void save(UserInfo userInfo) {
		if(StringUtils.isBlank(userInfo.getId())){
			userInfoDao.insert(userInfo);
			
		}else{
			UserInfo updateEntity=this.get(userInfo.getId());
			userInfoDao.update(updateEntity);
		 }
	}
	
	@Transactional(readOnly = false)
	public void delete(String ids) {
		String[] idArr=null;
		if(StringUtils.isNotBlank(ids)){
			idArr=ids.split(",");
			for(String id:idArr){
				userInfoDao.delete(id);
			}
		}
		
	}
}
